using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Schema;

namespace ns21
{
	internal class Class122
	{
		private Class123 class123_0 = new Class123();

		private Dictionary<Class124, Class121> dictionary_0 = new Dictionary<Class124, Class121>();

		private Class124 class124_0;

		public Class121 method_0(JsonSchema jsonSchema_0)
		{
			class123_0 = new Class123();
			class124_0 = method_1(null, jsonSchema_0);
			dictionary_0 = new Dictionary<Class124, Class121>();
			return method_7(class124_0);
		}

		public Class124 method_1(Class124 class124_1, JsonSchema jsonSchema_0)
		{
			string key;
			if (class124_1 != null)
			{
				if (class124_1.ReadOnlyCollection_0.Contains(jsonSchema_0))
				{
					return class124_1;
				}
				key = Class124.smethod_0(class124_1.ReadOnlyCollection_0.Union(new JsonSchema[1] { jsonSchema_0 }));
			}
			else
			{
				key = Class124.smethod_0(new JsonSchema[1] { jsonSchema_0 });
			}
			if (class123_0.Contains(key))
			{
				return class123_0[key];
			}
			Class124 @class = ((class124_1 != null) ? class124_1.method_0(jsonSchema_0) : new Class124(jsonSchema_0));
			class123_0.Add(@class);
			method_2(jsonSchema_0.Properties, @class.Dictionary_0);
			method_2(jsonSchema_0.PatternProperties, @class.Dictionary_1);
			if (jsonSchema_0.Items != null)
			{
				for (int i = 0; i < jsonSchema_0.Items.Count; i++)
				{
					method_4(@class, i, jsonSchema_0.Items[i]);
				}
			}
			if (jsonSchema_0.AdditionalItems != null)
			{
				method_6(@class, jsonSchema_0.AdditionalItems);
			}
			if (jsonSchema_0.AdditionalProperties != null)
			{
				method_5(@class, jsonSchema_0.AdditionalProperties);
			}
			if (jsonSchema_0.Extends != null)
			{
				foreach (JsonSchema extend in jsonSchema_0.Extends)
				{
					@class = method_1(@class, extend);
				}
				return @class;
			}
			return @class;
		}

		public void method_2(IDictionary<string, JsonSchema> idictionary_0, IDictionary<string, Class124> idictionary_1)
		{
			if (idictionary_0 == null)
			{
				return;
			}
			foreach (KeyValuePair<string, JsonSchema> item in idictionary_0)
			{
				method_3(idictionary_1, item.Key, item.Value);
			}
		}

		public void method_3(IDictionary<string, Class124> idictionary_0, string string_0, JsonSchema jsonSchema_0)
		{
			idictionary_0.TryGetValue(string_0, out var value);
			idictionary_0[string_0] = method_1(value, jsonSchema_0);
		}

		public void method_4(Class124 class124_1, int int_0, JsonSchema jsonSchema_0)
		{
			Class124 class124_2 = ((class124_1.List_0.Count > int_0) ? class124_1.List_0[int_0] : null);
			Class124 @class = method_1(class124_2, jsonSchema_0);
			if (class124_1.List_0.Count <= int_0)
			{
				class124_1.List_0.Add(@class);
			}
			else
			{
				class124_1.List_0[int_0] = @class;
			}
		}

		public void method_5(Class124 class124_1, JsonSchema jsonSchema_0)
		{
			class124_1.Class124_0 = method_1(class124_1.Class124_0, jsonSchema_0);
		}

		public void method_6(Class124 class124_1, JsonSchema jsonSchema_0)
		{
			class124_1.Class124_1 = method_1(class124_1.Class124_1, jsonSchema_0);
		}

		private Class121 method_7(Class124 class124_1)
		{
			if (dictionary_0.TryGetValue(class124_1, out var value))
			{
				return value;
			}
			value = Class121.smethod_0(class124_1.ReadOnlyCollection_0);
			dictionary_0[class124_1] = value;
			foreach (KeyValuePair<string, Class124> item in class124_1.Dictionary_0)
			{
				if (value.IDictionary_0 == null)
				{
					value.IDictionary_0 = new Dictionary<string, Class121>();
				}
				value.IDictionary_0[item.Key] = method_7(item.Value);
			}
			foreach (KeyValuePair<string, Class124> item2 in class124_1.Dictionary_1)
			{
				if (value.IDictionary_1 == null)
				{
					value.IDictionary_1 = new Dictionary<string, Class121>();
				}
				value.IDictionary_1[item2.Key] = method_7(item2.Value);
			}
			foreach (Class124 item3 in class124_1.List_0)
			{
				if (value.IList_1 == null)
				{
					value.IList_1 = new List<Class121>();
				}
				value.IList_1.Add(method_7(item3));
			}
			if (class124_1.Class124_0 != null)
			{
				value.Class121_0 = method_7(class124_1.Class124_0);
			}
			if (class124_1.Class124_1 != null)
			{
				value.Class121_1 = method_7(class124_1.Class124_1);
			}
			return value;
		}
	}
}
